load("//tools:defaults.bzl", "angular_jasmine_test", "ng_web_test_suite", "ts_project")

package(default_visibility = ["//visibility:public"])

UTILS = [
    "linker/source_map_util.ts",
]

ts_project(
    name = "test_utils",
    testonly = True,
    srcs = UTILS,
    deps = [
        "//:node_modules/source-map",
        "//packages/compiler",
    ],
)

ts_project(
    name = "test_lib",
    testonly = True,
    srcs = glob(
        ["**/*.ts"],
        exclude = UTILS + [
            "**/*_node_only_spec.ts",
        ],
    ),
    # Visible to //:saucelabs_unit_tests_poc target
    visibility = ["//:__pkg__"],
    deps = [
        ":test_utils",
        "//:node_modules/rxjs",
        "//:node_modules/zone.js",
        "//packages/animations",
        "//packages/animations/browser",
        "//packages/animations/browser/testing",
        "//packages/common",
        "//packages/common/locales",
        "//packages/compiler",
        "//packages/core",
        "//packages/core/rxjs-interop",
        "//packages/core/src/di/interface",
        "//packages/core/src/interface",
        "//packages/core/src/reflection",
        "//packages/core/src/util",
        "//packages/core/testing",
        "//packages/localize/init",
        "//packages/platform-browser",
        "//packages/platform-browser/animations",
        "//packages/platform-browser/testing",
        "//packages/platform-server",
        "//packages/private/testing",
        "//packages/router",
        "//packages/router/testing",
    ],
)

ts_project(
    name = "test_node_only_lib",
    testonly = True,
    srcs = glob(
        ["**/*_node_only_spec.ts"],
        exclude = UTILS,
    ),
    deps = [
        ":test_lib",
        ":test_utils",
        "//packages/compiler",
        "//packages/core",
        "//packages/core/src/compiler",
        "//packages/core/testing",
        "//packages/platform-server",
        "//packages/platform-server/testing",
        "//packages/private/testing",
    ],
)

angular_jasmine_test(
    name = "test",
    data = [
        ":test_lib",
        ":test_node_only_lib",
    ],
    shard_count = 4,
)

ng_web_test_suite(
    name = "test_web",
    external = ["@angular/platform-server"],
    deps = [
        ":test_lib",
    ],
)
